package com.ejuornal.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.ejuornal.bean.SystemInfo;
import com.ejuornal.dao.impl.SystemInfoDaoImpl;
import com.ejuornal.service.SystemInfoService;

/**
 * 系统信息
 * 
 * @author 石亚博
 */
@Component("systemInfoService")
public class SystemInfoServiceImpl implements SystemInfoService {
	private SystemInfoDaoImpl systemInfoDao;

	public SystemInfoDaoImpl getSystemInfoDao() {
		return systemInfoDao;
	}

	@Resource(name = "systemInfoDao")
	public void setSystemInfoDao(SystemInfoDaoImpl systemInfoDao) {
		this.systemInfoDao = systemInfoDao;
	}

	public void add(SystemInfo systemInfo) {
		String sql = "INSERT INTO t_systemInfo VALUES(?, ?, ?)";
		systemInfoDao.add(sql, new Object[] { null, systemInfo.getItemName(),
				systemInfo.getItemValue() });
	}

	public void update(SystemInfo systemInfo) {
		String sql = "UPDATE t_systemInfo SET itemName = ?, itemValue = ? WHERE systemId = ?";
		systemInfoDao.update(sql, new Object[] { systemInfo.getItemName(),
				systemInfo.getItemValue(), systemInfo.getSystemId() });
	}

	public void delete(int[] systemId) {
		String sql = "DELETE FROM t_systemInfo WHERE systemId = ?";
		systemInfoDao.batchDelete(sql, systemId);
	}

	public SystemInfo findById(int systemInfoId) {
		return systemInfoDao.findById(systemInfoId);
	}

	public List<SystemInfo> findAll() {
		return systemInfoDao.findAll();
	}

	@Override
	public SystemInfo findByName(String itemName) {
		return systemInfoDao.findByName(itemName);
	}
}
